class SessionsController < ApplicationController
#skip_before_filter :confirm_logged_in, :only => [:new,:index, :create , :destroy]
skip_before_filter :confirm_is_admin, :only => [:new, :index, :create, :destroy]
skip_before_filter :confirm_logged_in, :only =>[:new, :create]
def new
end
def index
end
def create
user = User.authenticate(params[:email], params[:password])
if user.nil?
  flash[:notice] = "Fel vid lösenord och användarnamn"
  redirect_to :action => 'new'
else
  if user.admin
    session[:user_id] = user.id
    redirect_to dev_projects_path
  else user
    session[:user_id] = user.id
    redirect_to user_path(user.id)
  end
end
end
  def destroy
    session[:user_id] = nil
    redirect_to root_url, :notice => "Logged out!"
  end
end